<template>
  <a-result status="404" title="404" sub-title="抱歉, 你访问的页面不存在。">
    <template #extra>
      <a-button type="primary" @click="$router.push('/')">返回首页</a-button>
      <!-- <a-button @click="close">ceshi </a-button> -->
      <component name="好的" :is="comList.a"></component>
      <!-- <Ceshi2></Ceshi2> -->
      <!-- <ceshi4 name="好的"> </ceshi4> -->
      <!-- <h4>active: {{ active }}</h4>
      <Tabs v-model="active">
        <Tab name="one">one</Tab>
        <Tab name="two">two</Tab>
        <Tab name="three" ref="childRef">three</Tab>
      </Tabs>
      <button @click="active = 'one'">选中第一个</button>
      <button @click="active = 'two'">选中第二个</button>
      <button @click="active = 'three'">选中第三个</button>
      <button @click="handleClick">选中第三个</button> -->
    </template>
  </a-result>
</template>

<script setup lang="ts">
import * as Vue from "vue";
import * as routeVue from "vue-router";
import { loadRemoteComponent } from "@/utils";
import { defineAsyncComponent, watch } from "vue";
import Tabs from "@/components/TestRelation/Tabs.vue";
import Tab from "@/components/TestRelation/Tab.vue";
import { EuroTwoTone } from "@ant-design/icons-vue";

const active = ref("two");
const childRef = ref();
const handleClick = () => {
  childRef.value.toggle();
  setTimeout(() => {
    // console.log(active.value);
  }, 1000);
};
const selectFirst = () => {
  active.value = "one";
};
let comList = {
  a: defineAsyncComponent(() => {
    return loadRemoteComponent("/remote/ListWebSite/ListWebSite.umd.js");
  }),
};
const Ceshi = defineAsyncComponent(() => {
  return loadRemoteComponent("/remote/AsyncComponent/Async.umd.js");
});
// const Ceshi2 = defineAsyncComponent(() => {
//   return loadRemoteComponent("/remote/ListWebSite/ListWebSite.umd.js");
// });

const test = async function (funstr: string) {
  const cri = await fetch("/remote/ListWebSite/ListWebSite.umd.js").then(
    (res) => res.text()
  );
  const module = {
    exports: {},
  };
  const exports = {};
  const require = (id: string) => {
    if (id == "vue") {
      return Vue;
    }
    if (id == "vue-router") {
      return routeVue;
    }
  };
  const fun = new Function("module", "exports", "require", cri);
  fun(module, exports, require);

  return {
    default: module.exports,
  };
};

var resul = await test("");
const ceshi4 = resul.default;

let str = "object";
let unicodeArray = [];

for (let i = 0; i < str.length; i++) {
  unicodeArray.push(str.charCodeAt(i));
}

// console.log(unicodeArray); // 输出[72, 101, 108, 108, 111]
// import MyWorker from "../utils/worker.ts?worker";
// import "../utils/demo_type/index";
// const worker = new MyWorker();

// onMounted(() => {
//   worker.postMessage("开启线程");
//   worker.onmessage = (e: { data: string }) => {
//     // console.log(e.data);
//     setTimeout(() => {
//       worker.postMessage("线程关闭");
//       worker.terminate();
//     }, 1000);
//   };
// });
const close = () => {
  // 获取当前打开的所有标签页
  // 重新跳转到新的页面
  // window.location.href = "https://www.example.com";
};
</script>
